# -*- coding = utf-8 -*-
# @Time : 2022/1/19 10:39
# @Author : 龙王赘婿_彪少
# @File : pngtopdf.py
# @Software: PyCharm

# 将png图片批量生成pdf供胡导打印

from reportlab.lib.pagesizes import portrait
from reportlab.pdfgen import canvas
from PIL import Image


def jpg_to_pdf(jpg, pdf_path):
    (w, h) = Image.open(jpg).size
    user = canvas.Canvas(pdf_path, pagesize=portrait((w, h)))
    user.drawImage(jpg, 0, 0, w, h)
    user.showPage()
    user.save()


if __name__ == '__main__':
    jpg_path = '../file/picture.jpg'
    pdf_path = '../file/picture.pdf'
    jpg_to_pdf(jpg_path, pdf_path)
